!(function () {
    // 借助工具http://www.spritecow.com/来获得定位，需要微调一下
    var WawaImagePositionMap = [
        {
            x: 0,
            y: 96
        },
        {
            x: 2,
            y: 129
        },
        {
            x: 3,
            y: 168
        },
        {
            x: 33,
            y: 96
        },
        {
            x: 36,
            y: 132
        },
        {
            x: 37,
            y: 168
        },
        {
            x: 65,
            y: 98
        },
        {
            x: 100,
            y: 97
        },
    ];
    var Wawa = window.Wawa = function () {
        // 宽高
        this.w = 32;
        this.h = 32;

        // 娃娃图片
        let randomImage = WawaImagePositionMap[parseInt(Math.random() * WawaImagePositionMap.length)];
        this.imageX = randomImage.x;
        this.imageY = randomImage.y;

        // 随机出现位置
        this.x = Math.random() * game.canvasWidth;
        this.y = Math.random() * (game.canvasHeight - game.safeTopHeight - this.h) + game.safeTopHeight;

        // 托管到game上
        game.wawaArr.push(this);
    }

    Wawa.prototype.render = function () {
        game.ctx.drawImage(game.R.wawa, this.imageX, this.imageY, this.w, this.h, this.x, this.y, this.w, this.h);
    }

    Wawa.prototype.update = function () {
        this.x += 0.5;
        if (this.x > game.canvasWidth) {
            this.x = -this.w;
        }
    }

})()